﻿//
// (C) Copyright 2009 Irantha Suwandarathna (irantha@gmail.com)
// All rights reserved.
//

using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Data;
using System.Threading;
using EffiProz.Core;
using EffiProz.Core.Lib;
using EffiProz.Core.Persist;


namespace EffiProz.Test.SelfTest 
{
    /// <summary>
    /// Summary description for TestMainScript
    /// </summary>
    [TestClass]
    public class TestMainScript :BaseTest
    {
      
#if !WindowsCE  
        string testScriptPath = "../../../Test/SelfTest/Scripts/";
#else
        string testScriptPath = "Storage Card/";
#endif


        public TestMainScript() : base()
        {
       
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void TestSelf()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelf.txt";
            TestUtil.testScript(sessionProxy, scriptPath);

        }

        [TestMethod]
        public void TestSelf_MVCC()
        {
            EffiProzProperties props = new EffiProzProperties();
            props.setProperty(EffiProz.Core.Persist.EffiProzDatabaseProperties.effiproz_tx, "MVCC");
            SessionInterface sessionProxy = ConnectToMemoryDB(props);
            string scriptPath = testScriptPath + "TestSelf.txt";
            TestUtil.testScript(sessionProxy, scriptPath);

        }

        [TestMethod]
        public void TestSelf_MVLOCKS()
        {
            EffiProzProperties props = new EffiProzProperties();
            props.setProperty(EffiProz.Core.Persist.EffiProzDatabaseProperties.effiproz_tx, "MVLOCKS");
            SessionInterface sessionProxy = ConnectToMemoryDB(props);
            string scriptPath = testScriptPath + "TestSelf.txt";
            TestUtil.testScript(sessionProxy, scriptPath);

        }

        [TestMethod]
        public void TestSelfAlterTable()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfAlterTable.txt";
            TestUtil.testScript(sessionProxy, scriptPath);

        }

        [TestMethod]
        public void TestSelfAlterColumn()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfAlterColumn.txt";
            TestUtil.testScript(sessionProxy, scriptPath);

        }

        [TestMethod]
        public void TestSelf3PartNames()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelf3PartNames.txt";
            TestUtil.testScript(sessionProxy, scriptPath);

        }

        [TestMethod]
        public void TestSelfArithmetic()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfArithmetic.txt";
            TestUtil.testScript(sessionProxy, scriptPath);

        }

        [TestMethod]
        public void TestSelfCasewhen()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfCasewhen.txt";
            TestUtil.testScript(sessionProxy, scriptPath);
        }

        [TestMethod]
        public void TestSelfCheckConstraints()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfCheckConstraints.txt";
            TestUtil.testScript(sessionProxy, scriptPath);

        }

        [TestMethod]
        public void TestSelfColGrant()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfColGrant.txt";
            TestUtil.testScript(sessionProxy, scriptPath);

        }

        [TestMethod]
        public void TestSelfConversions()
        {
           string scriptPath = testScriptPath + "TestSelfConversions.txt";
           TestUtil.testScript(sessionProxy, scriptPath);
            
        }

        [TestMethod]
        public void TestSelfCreate()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfCreate.txt";
            TestUtil.testScript(sessionProxy, scriptPath);       
        }

        [TestMethod]
        public void TestSelfFieldLimits()
        {
            string scriptPath = testScriptPath + "TestSelfFieldLimits.txt";
            TestUtil.testScript(sessionProxy, scriptPath);

        }


        [TestMethod]
        public void TestSelfFKModes()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();   
            string scriptPath = testScriptPath + "TestSelfFKModes.txt";
            TestUtil.testScript(sessionProxy, scriptPath);      
         
        }

        [TestMethod]
        public void TestSelfGrantees()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();     
            string scriptPath = testScriptPath + "TestSelfGrantees.txt";
            TestUtil.testScript(sessionProxy, scriptPath);
        }

        [TestMethod]
        public void TestSelfGroupBy()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB(); 
            string scriptPath = testScriptPath + "TestSelfGroupBy.txt";
            TestUtil.testScript(sessionProxy, scriptPath);
        }

        [TestMethod]
        public void TestSelfInPredicateReferencing()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();      
            string scriptPath = testScriptPath + "TestSelfInPredicateReferencing.txt";
            TestUtil.testScript(sessionProxy, scriptPath);           
        }

        [TestMethod]
        public void TestSelfInsertDeleteQueries()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfInsertDeleteQueries.txt";
            TestUtil.testScript(sessionProxy, scriptPath);     

        }

        [TestMethod]
        public void TestSelfIssues()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfIssues.txt";
            TestUtil.testScript(sessionProxy, scriptPath);
        }

        [TestMethod]
        public void TestSelfInternalFunctions()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfInternalFunctions.txt";
            TestUtil.testScript(sessionProxy, scriptPath);         
        }

        [TestMethod]
        public void TestSelfInterval()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfInterval.txt";
            TestUtil.testScript(sessionProxy, scriptPath);
        }

        [TestMethod]
        public void TestSelfJoins()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfJoins.txt";
            TestUtil.testScript(sessionProxy, scriptPath);            
        }

        [TestMethod]
        public void TestSelfLeftJoin()
        {       
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfLeftJoin.txt";
            TestUtil.testScript(sessionProxy, scriptPath); 
        }

        [TestMethod]
        public void TestSelfMultiGrants()
        {    
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfMultiGrants.txt";
            TestUtil.testScript(sessionProxy, scriptPath); 
        }

        [TestMethod]
        public void TestSelfNameResolution()
        {       
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfNameResolution.txt";
            TestUtil.testScript(sessionProxy, scriptPath); 
        }

        [TestMethod]
        public void TestSelfNameResolutionSchemas()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfNameResolutionSchemas.txt";
             TestUtil.testScript(sessionProxy, scriptPath);
          
        }

        [TestMethod]
        public void TestSelfNot()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfNot.txt";
            TestUtil.testScript(sessionProxy, scriptPath);

        }

        [TestMethod]
        public void TestSelfPrimaryKeys()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfPrimaryKeys.txt";
            TestUtil.testScript(sessionProxy, scriptPath);          
        }

        [TestMethod]
        public void TestSelfQueries()
        {           
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfQueries.txt";
            TestUtil.testScript(sessionProxy, scriptPath);  
        }

        [TestMethod]
        public void TestSelfRightCaching()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfRightCaching.txt";
            TestUtil.testScript(sessionProxy, scriptPath);
        }

        [TestMethod]
        public void TestSelfRoleNesting()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfRoleNesting.txt";
            TestUtil.testScript(sessionProxy, scriptPath); 
        }

        [TestMethod]
        public void TestSelfSchemaCasc()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfSchemaCasc.txt";
            TestUtil.testScript(sessionProxy, scriptPath);
        }

        [TestMethod]
        public void TestSelfSubselects()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfSubselects.txt";
            TestUtil.testScript(sessionProxy, scriptPath);
            
        }

        [TestMethod]
        public void TestSelfSysTables()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfSysTables.txt";
            TestUtil.testScript(sessionProxy, scriptPath);          
        }

        [TestMethod]
        public void TestSelfTransaction()
        {
           SessionInterface sessionProxy = ConnectToMemoryDB();
           string scriptPath = testScriptPath + "TestSelfTransaction.txt";
           TestUtil.testScript(sessionProxy, scriptPath);          
        }

        [TestMethod]
        public void TestSelfUnions()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfUnions.txt";
            TestUtil.testScript(sessionProxy, scriptPath);
        }

        [TestMethod]
        public void TestSelfTrimSimplified()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfTrimSimplified.txt";
            TestUtil.testScript(sessionProxy, scriptPath); 
        }


        [TestMethod]
        public void TestSelfUserFunction()
        {
           SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfUserFunction.txt";
            TestUtil.testScript(sessionProxy, scriptPath);          
        }

        [TestMethod]
        public void TestSelfViewGrants()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfViewGrants.txt";
            TestUtil.testScript(sessionProxy, scriptPath);
         
        }

        [TestMethod]
        public void TestSelfViews()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfViews.txt";
            TestUtil.testScript(sessionProxy, scriptPath);

        }

        [TestMethod]
        public void TestSelfViewSchemaResolve()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfViewSchemaResolve.txt";
            TestUtil.testScript(sessionProxy, scriptPath);           
        }

        [TestMethod]
        public void TestSelfTriggers()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfTriggers.txt";
            TestUtil.testScript(sessionProxy, scriptPath);
        }

        [TestMethod]
        public void TestSelfSchemaQuoting()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfSchemaQuoting.txt";
            TestUtil.testScript(sessionProxy, scriptPath);
        }

        [TestMethod]
        public void TestSelfMerge()
        {
            SessionInterface sessionProxy = ConnectToMemoryDB();
            string scriptPath = testScriptPath + "TestSelfMerge.txt";
            TestUtil.testScript(sessionProxy, scriptPath);

        }    
   


    }
}
